<?php

/**
 * 
 *
 * @author Anthony Straetman
 *
 */
class RouteController extends PlonkController {

	/**
	 * The views allowed for this module
	 * @var array
	 */
	protected $views = array(
		'route', 'create'
	);

	/**
	 * The actions allowed for this module
	 * @var array
	 */
	protected $actions = array(
		'create'
	);

	/**
	 * The form errors
	 * @var array
	 */
	private $formErrors = array();

	public function doCreate() {
		
	}

	public function showCreate() {
		// ---------- Safety stuff ---------- //
		if (!PlonkSession::exists('id')) {
			PlonkWebsite::redirect($_SERVER['PHP_SELF'] . '?' . PlonkWebsite::$moduleKey . '=restricted');
		}

		// ---------- Main template stuff ---------- //
		$this->setNavigationOptions();
		$this->mainTpl->assignOption('oMapsScript');
		$this->mainTpl->assign('pageTitle', 'Create route');
		$this->mainTpl->assign('pageMeta', '<link rel="stylesheet" href="modules/route/css/create.css" />' . PHP_EOL . '<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=false"></script>' . PHP_EOL . '<script type="text/javascript" src="core/js/markermanager_packed.js"></script>' . PHP_EOL . '<script type="text/javascript" src="modules/route/js/create.js"></script>');
		// ---------- Page template stuff ---------- //
		// ---------- Other stuff  ---------- //
	}

	public function showRoute() {
		// ---------- Main template stuff ---------- //
		$this->setMainTemplate();

		// ---------- Page template stuff ---------- //
		// ---------- Other stuff  ---------- //
	}

	private function setNavigationOptions() {
		if (PlonkSession::exists('id')) {
			// User logged in
			$this->mainTpl->assignOption('oLogout');
		} else {
			// User logged out
			$this->mainTpl->assignOption('oLogin');
			$this->mainTpl->assignOption('oRegister');
		}
	}

	private function setMainTemplate() {
		$this->mainTpl->assign('pageTitle', 'Routes');
		$this->mainTpl->assign('pageMeta', '<link rel="stylesheet" href="modules/route/css/route.css" />' . PHP_EOL . '<script type="text/javascript" src="modules/route/js/create.js"></script>');

		$this->setNavigationOptions();
	}

}

// EOF